<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery-3.6.0.min.js"></script>
</head>

<body>
    <h1>hello world!</h1>
    <h3 id="h3"></h3>
    <form action="http://localhost:3003/api/uploads" method="post" enctype="multipart/form-data">
        <input type="file" id="fileInput" name="file">
        <input type="submit">
    </form>
    

    <input type="file" id="fileInput">
    <button onclick="uploadFile()" >上传文件</button>

    <script>

        let new1 = '原内容'
        let new2 = '这是一个改变了的文件内容'
        let new3 = '又变回来了'
        let flag = 1

        let x = $("#h3")
        x.html(new1)

        x.click(
            () => {
                if (flag === 1) {
                    console.log(111);

                    x.html(new2)
                    flag = 0
                } else {
                    x.html(new3)
                    flag = 1
                }
            }
        )

<<<<<<< HEAD
        function uploadFile(){

            const fileInput = document.getElementById("fileInput");
            
            const file = fileInput.files;
            
            if(!file){
                alert("请选择文件");
                return;
                
            }
            
            const formData = new FormData();
            formData.append('file', file);
            console.log(file[0]);
            $.ajax({
                url: "http://localhost:/phpfiledemo/upload.php",
                type: "POST",
                data: formData,
                processData: false,  // 告诉jQuery不要处理数据
                contentType: false,   // 告诉jQuery不要设置Content-Type
                success: function (response) {
                    alert('上传成功: ' + response.path);
                },
                error: function (xhr) {
                    alert('上传失败: ' + xhr.responseText);
                }
    
            })

        }
=======
       
>>>>>>> origin/master


    </script>

</body>


</html>